package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckGroupDao {

    //分页查询
    Page<CheckGroup> page(@Param("checkGroupQueryString") String queryString);

    //新增检查组
    void insert(CheckGroup checkGroup);

    //将检查组id和检查项id加入关联表
    void insertBatch(Integer checkGroupId,  Object checkItemId);

    //根据id删除检查组id
    @Delete("delete from t_checkgroup where id = #{id}")
    void deleteById(Integer id);

    //根据groupId删除关联表中的数据
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    void deleteByGroupId(Integer id);

    //查找套餐表检查组关联表中是否有关联组的id
    @Select("select COUNT(*) from t_setmeal_checkgroup where checkgroup_id = #{id}")
    Integer countGroupById(Integer id);

    //修改检查组中的内容
    void updateById(CheckGroup checkGroup);

    //回显检查组
    @Select("select * from t_checkgroup where id = #{id} ")
    CheckGroup show(Integer id);

    //回显检查项
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    List<Integer> showCheckItem(Integer id);

    //回显套餐中的检查组
    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();

}
